

import { instance } from "./api.interceptor"
import { IFile, IUploadFileDto, } from "../interfaces"


export const ImageFileService = {
    async getOne(imageFileId: number):Promise<IFile> {
        const resp = await instance.get<IFile>(`/image/file/${imageFileId}`)
        return resp.data
    },

    async uploadFile(dto: IUploadFileDto):Promise<IFile> {
        const formData = new FormData();
        formData.append("file", dto.file[0]);
        const res = await instance.post<IFile>("/image/file", formData, {
            headers: {
                "Content-Type": "multipart/form-data",
            }
        })
        return res.data
    }

}
